<?php
if(!defined('IN_WOGU')) {
    exit('Access Denied');
}

Loader::loadUserClass('FrontController', false, 'member');

class Member_AccountController extends FrontController
{
    protected $_rl = null;
    
    public function getRl() {
        if(!$this->_rl) {
            $this->_rl = Loader::loadUserModel('RlModel', true, 'member');
        }
        
        return $this->_rl;
    }
    
    public function registerAction() {
        if(MemberCookie::userid()) {
            showmessage($this->_lang['already_logined'], '/');
        }

        $this->_view->head_title = $this->_lang['register'];
        $this->_view->display('register');
    }
    
    public function doregisterAction() {
        if(MemberCookie::userid()) {
            showmessage($this->_lang['already_logined'], '/');
        }

        if(!$this->getRl()->register($_POST)) {
            exit($this->getRl()->getLastError());
        }
        
        exit('1');
    }
    
    public function logoutAction() {
        $this->getRl()->logout();
        showmessage($this->_lang['logout_success'], '/');
    }
}